﻿using System.Collections.Generic;
using GeneticAlgorithms.Alphabets;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GeneticAlgorithms.Tests.Alphabets
{
    [TestClass]
    public class LettersAlphabetTest : BaseAlphabetTest
    {
        private static HashSet<char> FillLetters(char start, char end, HashSet<char> letters)
        {
            for (int i = start; i <= end; ++i)
            {
                letters.Add((char)i);
            }
            return letters;
        }

        private static HashSet<char> GetUppercaseLetters()
        {
            return FillLetters('A', 'Z', new HashSet<char>());
        }

        private static HashSet<char> GetLowercaseLetters()
        {
            return FillLetters('a', 'z', new HashSet<char>());
        }

        private static HashSet<char> GetAllcasesLetters()
        {
            return FillLetters('a', 'z', GetUppercaseLetters());
        }

        protected override IAlphabetTestHelper CreateHelper()
        {
            return new AlphabetTestHelper<LettersAlphabet, char>(
                (g, i) => { },
                delegate
                {
                    return new LettersAlphabet(LetterCases.All);
                },
                GetAllcasesLetters(),
                new HashSet<char>() { '1', '*', '-', '0' },
                true
            );
        }
    }
}
